package com.woniuxy.his.mapper;

import com.woniuxy.his.entity.Case;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.his.entity.Patient;
import com.woniuxy.his.vo.InspectVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 病历表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
public interface CaseMapper extends BaseMapper<Case> {


    @Select("select hcase.patient_name,hi.item_name,hc.case_id,hcd.check_detail_id " +
            //-- 检查表
            "from his_check hc " +
            //-- 检查详情表
            "join his_check_detail hcd " +
            //-- 检查项目表
            "join his_item hi " +
            //-- 病历表
            "join his_case hcase " +
            "on hc.check_id = hcd.check_id " +
            "and hc.case_id = hcase.case_id " +
            "and hcd.item_id = hi.item_id " +
            "WHERE hc.ispaid='yes' " +
            "and hcase.patient_name = #{patientName}")
    List<InspectVo> findInspectByPatientName(String patientName);

    @Insert("insert into his_case (patient_name,patient_id) values(#{patientName},#{patientId})")
    Integer insertCasePatientIdAndName(Patient patient);

}
